<?php if (!defined('BASEPATH')) exit('No direct script access allowed');

/**
 *
 * base_url/gallery
 *
 * @package    controllers
 * @author     Bertrand Kintanar <bertrand.kintanar@gmail.com>
 * @version    $Id: gallery.php 214 2011-12-08 21:01:26Z bertrand.kintanar@gmail.com $
 * @copyright  &copy; 2011 NaCl.org WebGroup
 *
 */
class Gallery extends MY_Controller {

    
    public function __construct()
    {
        parent::__construct();
        parent::_get_script(__FILE__);
    }
    
    public function index()
    {
        $_gallery_album_obj = new \models\GalleryAlbum;
        $_gallery_albums    = $_gallery_album_obj->getGalleryAlbums();
        
        $this->smarty->assign('load_modal', true);
		$this->smarty->assign('gallerific_js', true);
        $this->smarty->assign('gallery_albums', $_gallery_albums);

        $this->smarty->assign('main_content', 'gallery.tpl');
        $this->smarty->view();
    }

    public function load_gallery_album_images()
    {
        $_gallery_album_obj       = new \models\GalleryAlbum;
        $_gallery_album_photo_obj = new \models\GalleryAlbumPhoto;
        
        $_gallery_albums          = $_gallery_album_obj->getGalleryAlbums();
        
        $json = array();
        foreach($_gallery_albums as $_gallery_album)
        {
            $_gallery_album_photos = $_gallery_album->getGalleryAlbumPhotos();
            
            $photos = $_gallery_album_photo_obj->getGalleryAlbumPhotosByGalleryAlbumId($_gallery_album->gallery_album_id);
            
            $gallery_album['album_obj']  = $_gallery_album;
            $gallery_album['album_sha1'] = $_gallery_album->getGalleryAlbumNameSHA1();
            $gallery_album['photos_obj'] = $photos;

            $json[] = $gallery_album; 
        }

        print( json_encode( $json ) );
    }
}


